package co.yixiang.huiMin.service.impl;

import co.yixiang.huiMin.entity.CarTypes;
import co.yixiang.huiMin.mapper.CarTypesMapper;
import co.yixiang.huiMin.service.CarTypesService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 车辆类型 服务实现类
 * </p>
 *
 * @author Author
 * @since 2020-08-04
 */
@Service
public class CarTypesServiceImpl extends ServiceImpl<CarTypesMapper, CarTypes> implements CarTypesService {

    @Resource
    private CarTypesMapper carTypesMapper;

    @Override
    public List<CarTypes> selectCarTypes() {
        QueryWrapper<CarTypes> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("del_flag",0).orderByDesc("create_time");
        return carTypesMapper.selectList(queryWrapper);
    }

    @Override
    public int insertCarTypes(CarTypes carTypes) {
        carTypes.setCreateTime(LocalDateTime.now());
        return carTypesMapper.insert(carTypes);
    }

    @Override
    public CarTypes selectCarTypesById(String id) {
        return carTypesMapper.selectById(id);
    }

    @Override
    public int updateCarTypes(CarTypes carTypes) {
        return carTypesMapper.updateById(carTypes);
    }
}
